package com.protocols;

import java.io.Serializable;
import java.nio.ByteBuffer;

public class BinaryInteger implements Serializable{
	private int Value;
	private int Length;
	private int Offset=0;
	
	public BinaryInteger() {
		Value = 0;
		Length = 0;
	}

		
	public BinaryInteger(int length, int offset) {
		Value = 0;
		Length = (length>7?7:length);
		Offset=offset;
	}
	
	public BinaryInteger(int val,int length, int offset) {
		Length = (length>7?7:length);
		Value = (val>getMaxValue()?getMaxValue():val);
		Offset=offset;
		
	}

	private int getMaxValue(){
		return (int) (Math.pow(2, Length)-1);
	}
	
	public int getValue() {
		return Value;
	}
	
	public int getOffsetValue() {
		return Value<< Offset;
	}
	
	public void setValue(int value) {
		Value = (value>getMaxValue()?getMaxValue():value);
	}
	public int getLength() {
		return Length;
	}
	public void setLength(int length) {
		Length = (length>7?7:length);
	}
	
	

}
